<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
</html>

<script>
  const canvas = document.createElement("canvas");
  canvas.width = 600;
  canvas.height = 400;
  document.body.append(canvas);
  const context = canvas.getContext("2d");

  context.moveTo(100, 100); //开始位置，x，y
  context.lineTo(300, 100); //结束位置，x，y
  context.stroke(); // 调用画线的方法，就相当于是从x100 到 x300一条直线
</script>
